package ioexercise;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        //5. 写文本数据

        FileOutputStream fos=new FileOutputStream("1.txt",true);
        String line="锄禾日当午，汗滴禾下土。";
        byte[] data=line.getBytes(StandardCharsets.UTF_8);//将字符串按照utf-8的格式转化为字节数字
        fos.write(data);
        fos.write("谁知盘中餐，粒粒皆辛苦".getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        fos.close();


    }
}
